package com.zrrd.service.impl;

import com.zrrd.mapper.TeaMapper;
import com.zrrd.pojo.Tea;
import com.zrrd.service.TeaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title TeaServiceImpl
 * @description
 * @create 2024/1/24 11:38
 */
@Service
public class TeaServiceImpl implements TeaService {
    @Autowired
    private TeaMapper teaMapper;
    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public List<Tea> queryTeaAll() {

        return teaMapper.queryTeaAll();
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Override
    public Tea queryOneById(Integer id) {
        return teaMapper.queryOneById(id);
    }

    /**
     * 插入
     *
     * @param tea
     * @return
     */
    @Override
    public Integer addTea(Tea tea) {
        System.out.println("service-------"+tea);
        return teaMapper.insertTea(tea);
    }

    /**
     * 修改
     *
     * @param tea
     * @return
     */
    @Override
    public Integer updateTea(Tea tea) {
        return teaMapper.updateTea(tea);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public Integer removeTea(Integer id) {
        return teaMapper.deleteTea(id);
    }

    /**
     * 根据条件查询
     *
     * @param tea
     * @return
     */
    @Override
    public List<Tea> queryByCondition(Tea tea) {
        return teaMapper.queryByCondition(tea);
    }

    /**
     * 根据多个id查询
     *
     * @param ids
     * @return
     */
    @Override
    public List<Tea> queryByIds(List<Integer> ids) {
        return teaMapper.queryByIds(ids);
    }

    /**
     * 根据名称进行模糊查询
     *
     * @param info
     * @return
     */
    @Override
    public List<Tea> fuzzyQueryByNameInfo(String info) {
        //为接收到的info值，添加模糊查询%
        info="%"+info+"%";
        return teaMapper.fuzzyQueryByNameInfo(info);
    }
}
